//
//  MainViewController.swift
//  Renweiweibo
//
//  Created by as888 on 15/12/14.
//  Copyright © 2015年 任伟. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // 添加子控制器
        addChildViewController()
    }

    //添加所有的子控制器
    private func addChildViewController() {
        
        tabBar.tintColor = UIColor.orangeColor()
        
        addChildViewController(addChildViewController(HomeViewController(), title: "首页", imageName: "tabbar_home"))
        addChildViewController(addChildViewController(HomeViewController(), title: "消息", imageName: "tabbar_message_center"))
        addChildViewController(addChildViewController(HomeViewController(), title: "发现", imageName: "tabbar_discover"))
        addChildViewController(addChildViewController(HomeViewController(), title: "我", imageName: "tabbar_profile"))
    }
    
    // 添加指定控制器
    private func addChildViewController(vc: UIViewController, title: String, imageName: String) {
        
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        addChildViewController(UINavigationController(rootViewController: vc))
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
}
